//
//  ViewController.m
//  SkillCollection
//
//  Created by Lee on 2017/5/5.
//  Copyright © 2017年 cashpie. All rights reserved.
//

#import "ViewController.h"
#import "AllAppWorkspace.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIImage * image = [UIImage imageNamed:@"timg.jpeg"];
    self.view.layer.contents = (__bridge id _Nullable)(image.CGImage);
    self.view.layer.contentsRect = CGRectMake(0, 0, 1, 1);

    for (id item in AppWorkspace())
    {
        NSLog(@"applicationIdentifier===%@\n",[item performSelector:NSSelectorFromString(@"applicationIdentifier")]);
//        NSLog(@"bundleIdentifier===%@\n",[item performSelector:NSSelectorFromString(@"bundleIdentifier")]);
//        NSLog(@"bundleVersion===%@\n",[item performSelector:NSSelectorFromString(@"bundleVersion")]);
//        NSLog(@"shortVersionString===%@\n",[item performSelector:NSSelectorFromString(@"shortVersionString")]);
    }
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, 100, 160, 60);
    [button setTitle:@"设置" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor redColor];
    [button addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)buttonClicked{

    OpenSetting(UIApplicationOpenSettingsURLString);
}

static inline void OpenSetting(NSString *schemes){

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:schemes]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

#pragma clang diagnostic pop
